﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Automation;

namespace AutoWinUI
{
    public class WindowsMediaPlayer12
    {
        public static void TestWMP()
        {
            AutomationElement root = AutomationElement.RootElement;

            AutoElement ele = new AutoElement();
            ele.AutomationID = "";
            ele.ClassName = "WMP Skin Host";
            ele.Name = "Playback Controls View";
            ele.ParentElement = root;

            AutomationElement WMP = null;

            try
            {
                WMP = ele.FindFirst(SearchScope.Children);
                //PatternAction.InvokePatternInvokeAction(StartButton);

                //AutomationElementCollection stopButtons = null;
                AutoElement ele1 = new AutoElement();
                ele1.AutomationID = "";
                ele1.ClassName = "";
                ele1.Name = "Stop";
                ele1.ParentElement = WMP;
                AutomationElement stopButton = ele1.FindFirst2(SearchScope.Descendants);
                PatternAction.InvokePatternInvokeAction(stopButton);
            }
            catch (Exception ex)
            { // do this

            }
        }
    }
}
